<?php

namespace App\Exports;

use App\Models\Examination;
use Illuminate\Contracts\View\View;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;

class ExaminationExport implements FromView, ShouldAutoSize
{
    public $examinations;

    public function __construct(Request $request)
    {
        $this->examinations = Examination::query()
            ->select('id', 'name', 'subject_id', 'start_time', 'category_id', 'timer', 'over_time')
            ->with('category:id,name')
            ->with('subject:id,name')
            ->get();

    }

    public function view(): View
    {
        return view('exports.examination', [
            'examinations' => $this->examinations
        ]);
    }
}
